<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('训练成绩录入')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: bootstrap-select-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="data-form">
                <input class="control-label" id="scheduleTime" name="scheduleTime"  th:value="*{scheduleTime}" readonly="true" hidden="true">
                <input id="projectType" name="projectType"  th:value="*{projectType}" hidden="true">
                <input id="centerId" name="centerId"  th:value="*{centerId}" hidden="true">
                <input id="curChildId" name="curChildId"  th:value="*{curChildId}" hidden="true">
                <input id="courseId" name="courseId"  th:value="*{courseId}" hidden="true">
                <input id="isCurDay" name="isCurDay"  th:value="*{isCurDay}" hidden="true">
               <!-- <div class="panel blank-panel">

                    <div class="panel-heading">
                        <div class="panel-options">

                            <ul class="nav nav-tabs" th:each="studentBasics: *{students}">

                                <li class=""><a class="btn btn-default btn-rounded" th:onclick="|studentEntering(*{studentBasics.childId})|">
                                    <i th:text="*{studentBasics.childName}"></i></a>
                                </li>

                            </ul>
                        </div>
                    </div>

                    <div class="panel-body">
                        <div class="tab-content">
                            <div id="tab" class="tab-pane active">

                            </div>
                        </div>
                    </div>

                </div>-->
                <div class="panel-heading">
                    <div class="panel-options">
                        <ul class="nav nav-tabs nav-justified box-menu" id="box-menu">
                            <li  th:each="studentBasics:${students}" th:class="${studentBasics.index == 0 ? 'active' : ''}" ><a
                                    data-toggle="tab" th:onclick="|studentEntering(*{studentBasics.childId})|"
                                    th:id="'tab-menu-' + ${studentBasics.index}" ><span>[[${studentBasics.childName}]]</span></a>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="panel-body">
                    <div class="tab-content">
                        <div id="tab" class="tab-pane active">

                        </div>
                    </div>
                </div>

            </form>
        </div>

        <div class="row">
            <div class="col-sm-offset-5 col-sm-10">
                <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭</button>
            </div>
        </div>
    </div>
</div>



<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: bootstrap-select-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">

    var prefix = ctx + "education/childScheduleRecord";
    var gradeType = [[${@dict.getType('business_training_level')}]];

    $(function () {
        studentEntering($('#curChildId').val());
    });

    // 切换小孩展示该小孩的课程评分
    function studentEntering(studentId) {
        var formData = new FormData();
        formData.set("projectType", $('#projectType').val());
        formData.set("childId", studentId);
        formData.set("centerId",  $('#centerId').val());
        formData.set("trainingTime",  $('#scheduleTime').val());
        formData.set("courseId",  $('#courseId').val());
        formData.set("checkTime",  $('#isCurDay').val());
        $.ajax({
            url: prefix + '/listEnteringShow',
            data: formData,
            cache: false,
            contentType: false,
            processData: false,
            type: 'POST',
            success: function (result) {
                if (result.code == '0') {
                    var $tab = $("#tab");
                    $tab.html("");
                    if (result.data != null) {
                        for (var i = 0; i < result.data.length; i++) {
                            $tab.append("<div><p>" + (i+1) + "." + result.data[i].trainingContent + "</p>" +
                                "<input name='list["+ i +"].id' type='hidden' value='"+ result.data[i].id +"'>");
                            if (result.data[i].trainingLevel == null) {
                                $tab.append("<p>结果：&nbsp;&nbsp;&nbsp;暂无结果</p></div>");
                            }
                            else if(result.data[i].trainingLevel == 0){
                                $tab.append("<p>结果： &nbsp;&nbsp;&nbsp;"+ "<span><font color='#7fff00'>"+ $.table.selectDictLabel(gradeType, result.data[i].trainingLevel)+"</font></span>"+"</p></div>");
                            }
                            else if(result.data[i].trainingLevel == 1){
                                $tab.append("<p>结果： &nbsp;&nbsp;&nbsp;"+ "<span><font color='#7fff00'>"+ $.table.selectDictLabel(gradeType, result.data[i].trainingLevel)+"</font></span>"+"</p></div>");
                            }
                            else if(result.data[i].trainingLevel == 2){
                                $tab.append("<p>结果： &nbsp;&nbsp;&nbsp;"+ "<span><font color='#d2691e'>"+ $.table.selectDictLabel(gradeType, result.data[i].trainingLevel)+"</font></span>"+"</p></div>");
                            }
                            else if(result.data[i].trainingLevel == 3){
                                $tab.append("<p>结果： &nbsp;&nbsp;&nbsp;"+ "<span><font color='red'> "+$.table.selectDictLabel(gradeType, result.data[i].trainingLevel)+"</font></span>"+"</p></div>");
                            }
                            else if(result.data[i].trainingLevel == 5){
                                $tab.append("<p>结果： &nbsp;&nbsp;&nbsp;"+ "<span><font color='blue'>未训练</font></span>"+"</p></div>");
                            }
                        }
                    }
                }
                else {
                    $.modal.alertError(result.msg);
                }
            }
        });
    }
    //默认显示第一个
    $("#box-menu").children(":first-child").addClass('active');
    $(".mainbox:first-child .mod").addClass('active');

    $(".active").find(".boxss:first-child .tab-pane").addClass('active');

    $(".hover-box").hover(function(){
        $(this).find('.hover-btn').show();
    },function(){
        $(this).find('.hover-btn').hide();
    })

    //获取当前哪个
    var len=$('.mod.active').find(".box-tab li").length;
    //判断点击过的
    $("input:radio:checked").addClass('checked');
    $(".tab-pane.active").find(".hover-box").on("click",function (){
        $(this).find("input:radio").addClass('checked');
        $(this).siblings('.hover-box').find("input:radio").removeClass('checked');
    });
    fy();
    function fy(){
        var c=$('.mod.active').find('input');
        if(c.hasClass("checked")){
            // console.log("ccccccccc===",$(".checked").length)
            var box=$('.mod.active').find('.checked');
            for(var i=0;i< box.length;i++){

                var g=$('.mod.active').find('.checked').eq(i).attr('name');
                console.log("ggggg=",g)
                $(".mod.active").find("li[id='tab-q-"+g+"'] a").addClass('on');
            }
        }
    }

</script>
</body>

</html>